<?php

namespace App\Admin\Controllers\Data;

use App\Admin\Renders\CommonGrid;
use App\Models\Support;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;

class SupportController extends AdminController
{
    protected string $title = '赞助';

    public function grid(): Grid
    {
        $model = Support::ofAdmin()
            ->with(['chapter', 'player', 'season', 'user', 'gift']);

        return Grid::make($model, function (Grid $grid) {
            $grid->disableCreateButton();
            $grid->disableActions();

            if (Admin::user()->isAdministrator()) {
                $grid->column('application.name', '所属应用');
            }
            $grid->column('season.title', '赛季名称');
            $grid->column('chapter.title', '活动场次');

            CommonGrid::support($grid);
        });
    }
}
